import jieba
import sys


def read_data(file_name, out_file):
    """

    :param file_name: str
    :param out_file: str

    file format:
    class2, class1, class_name, shop_id, kdt_id, title
    """
    with open(out_file, 'w+') as fd:
        for i, l in enumerate(open(file_name)):
            # skip first line
            if i == 0:
                continue

            d = l.strip().split('\t')
            if len(d) != 2:
                print(d)
            else:
                class2, title = d[0], d[1]
                title2 = ' '.join(jieba.cut(title))
                fd.write(class2.strip() + '\t' + title2 + '\n')


if __name__ == '__main__':
    in_file = sys.argv[1]
    out_file = sys.argv[2]
    read_data(in_file, out_file)

